/*
 * @Author: your name
 * @Date: 2021-04-18 13:12:14
 * @LastEditTime: 2021-04-18 16:43:26
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \defining-struct\src\main.rs
 */
#[derive(Debug)]

/* 
struct User {
    username: String,
    email: String,
    sign_in_count: u64,
    active: bool,
}
fn build_user(email: String, username: String) -> User {
    User {
        email,
        username,
        active: true,
        sign_in_count: 1,
    }
}
}
*/
struct Rectangle {
    width:u32,
    height:u32,
}

//impl 是 implementation 的缩写
impl Rectangle {
    fn area(&self) -> u32 {
        self.width * self.height
    }
}
fn main() {

    let rect1 = Rectangle {width:30, height:50};

    println!("the area of the rectangle is {} square pixels", rect1.area());

    println!("Hello, world!");
}
